package com.joejag.mavenstats.client.service;

import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.rpc.RemoteService;
import com.google.gwt.user.client.rpc.ServiceDefTarget;
import com.joejag.mavenstats.client.dto.ProjectDTO;

import java.util.List;
import java.util.Map;

public interface ProjectsService extends RemoteService
{

  boolean addProject(ProjectDTO project);
  void editProject(ProjectDTO project);
  void deleteProject(ProjectDTO project);

  /**
   * @gwt.typeArgs <java.lang.String, java.util.List<com.joejag.mavenstats.client.dto.ProjectDTO>>
   */
  Map getProjects();

   /**
   * @gwt.typeArgs <java.lang.String>
   */
  List getTeamNames();

  /**
   * @gwt.typeArgs <com.joejag.mavenstats.client.dto.DependencyDTO>
   */
  List getDependencies(String projectURL);


  public static class App
  {
    private static ProjectsServiceAsync ourInstance = null;

    public static synchronized ProjectsServiceAsync getInstance()
    {
      if (ourInstance == null)
      {
        ourInstance = (ProjectsServiceAsync) GWT.create(ProjectsService.class);
        ((ServiceDefTarget) ourInstance).setServiceEntryPoint(GWT.getModuleBaseURL() + "com.joejag.mavenstats.MavenStats/ProjectsService");
      }
      return ourInstance;
    }
  }
}
